#ifndef REDIS_H_
#define REDIS_H_

#include "credis.h"
#include "model.h"
#include "value.h"

_Bool redis_open(const char *host);

void redis_close();

int redis_set_value(const device_t *device, const thing_model_t *tag, const value_t *value);

//val_list里面的item需要由value_free释放，val_list本身分配的内存需要由vector_clear释放
int redis_get_values(const device_t *device, const vector_t *tag_list, vector_t *val_list);

int redis_pub_value(const channel_t *channel, const device_t *device, const thing_model_t *tag, const value_t *value);

int redis_sub_value(value_id_t *id, value_t *value);

int redis_pub_bytes(const char *topic, const uint8_t *ptr, size_t nbytes);

int redis_sub_bytes(char **topic, uint8_t *ptr, size_t *nbytes);

int redis_subscribe(const char *topic);

#endif /* REDIS_H_ */
